package com.hanggold.jfinal.springframework.demo;

import com.hanggold.jfinal.springframework.bean.TTool;
import com.hanggold.jfinal.springframework.bean.User;
import com.hanggold.jfinal.springframework.bean.VolCar;
import org.springframework.beans.factory.annotation.AnnotatedGenericBeanDefinition;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.support.RootBeanDefinition;

/**
 * @author <a href="mailto:sunmch@163.com">smc</a>
 * @date 2019-09-29 14:11
 * @since 1.0.0
 **/
public class DefaultFactoryBeanDemo {

    public static void main(String[] args) {

        DefaultListableBeanFactory listableBeanFactory = new DefaultListableBeanFactory();

        RootBeanDefinition rootBeanDefinition = new RootBeanDefinition(TTool.class);

        RootBeanDefinition beanDefinition = new RootBeanDefinition(VolCar.class);

        BeanDefinition definition = new AnnotatedGenericBeanDefinition(User.class);

        listableBeanFactory.registerBeanDefinition("user", definition);

        listableBeanFactory.registerBeanDefinition("tool", rootBeanDefinition);

        listableBeanFactory.registerBeanDefinition("car", beanDefinition);

        User user = listableBeanFactory.getBean(User.class);


        user.car("volov");

        user.say("helloworld");


    }
}
